package html;

import java.awt.Frame;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;

public class HtmlPageSaveButton extends JButton implements ActionListener{
	
	private static final long serialVersionUID = 1L;
	private HtmlPage hp;
	private Frame owner;

	public HtmlPageSaveButton(HtmlBody hb,String tittle,Frame f) {
		this(new HtmlPage(tittle,hb),"",f);
	}

	public HtmlPageSaveButton(HtmlBody hb,String tittle,String text, Frame f) {
		this(new HtmlPage(tittle,hb),text,f);
	}

	public HtmlPageSaveButton(HtmlPage htmlPage,Frame f){
		this(htmlPage,"",f);
	}
	
	public HtmlPageSaveButton(HtmlPage htmlPage,String text,Frame f) {
		super(text,new ImageIcon(Logo.SAVE));
		this.setMargin(new Insets(0,0,0,10));
		hp=htmlPage;
		owner=f;
		addActionListener(this);
	}


	public void actionPerformed(ActionEvent e) {
		hp.exportToFile(owner);		
	}


}
